package adv3;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import adv2.Book;

public class MapTest2 {

	public static void main(String[] args) {
		Map map = new HashMap();
		map.put("狗", "dog");
		map.put("猫", "cat");
		map.put(null, "没有！");
		map.put("nothing", null);

		Object r1 = map.put(new Book("java从入门到放弃", "IT类", 1500), "这本书不错！");
		System.out.println("第一次返回:" + r1);
		Object r2 = map.put(new Book("java从入门到放弃", "犯罪类", 100), new Book(
				"mysql从删库到跑路！", "IT", 10));
		System.out.println("第2次返回:" + r2);
		System.out.println(map);
		// 迭代map
		Set keys = map.keySet();
		Iterator ir = keys.iterator();
		System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
		while (ir.hasNext()) {
			Object key = ir.next();
			Object value = map.get(key);
			System.out.println(key + "=" + value);
		}
	}
}
